package com.nest4cloud.nest.gateway.config;

import com.alibaba.nacos.shaded.io.grpc.internal.JsonUtil;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.stereotype.Component;

@Component
public class RoutePrinter {

    @Autowired
    private RouteLocator routeLocator;

    @PostConstruct
    public void printRoutes() {
        routeLocator.getRoutes()
            .subscribe(route -> {
                System.out.println("Route ID: " + route.getId());
                System.out.println("Predicates: " + route.getPredicate());
                System.out.println("Filters: " + route.getFilters());
                System.out.println("URI: " + route.getUri());
                System.out.println("JSON: " + route.toString());
            });
    }
}
